package com.zhyonk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhyonk.domain.ItemResultInfo;
import com.zhyonk.domain.ItemListInfo;
import com.zhyonk.domain.ItemQueryInfo;
import com.zhyonk.mapper.ItemResultInfoMapper;
import com.zhyonk.mapper.ItemListInfoMapper;
import com.zhyonk.mapper.ItemQueryInfoMapper;
import com.zhyonk.service.TestCommService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author cbl
 * @description com.zhyonk.service.impl
 * @date 2020/7/13
 */
@Service
public class TestCommServiceImpl implements TestCommService {

    @Autowired
    private ItemListInfoMapper testInfoMapper;

    @Autowired
    private ItemQueryInfoMapper titleInfoMapper;

    @Autowired
    private ItemResultInfoMapper resultInfoMapper;

    @Override
    public Page<ItemListInfo> queryTestAll(Map<String, String> map) {
        Integer start = Integer.getInteger("start");
        Integer end = Integer.getInteger("end");
        Page<ItemListInfo> testInfoPage = testInfoMapper.selectPage(new Page<>(start, end), null);
        return testInfoPage;
    }

    @Override
    public ItemListInfo queryTestById(Integer testId) {
        ItemListInfo testInfo = testInfoMapper.selectById(testId);
        return testInfo;
    }

    @Override
    public ItemQueryInfo queryTitleAll(String currTestId) {
        QueryWrapper<ItemQueryInfo> titleInfoWrapper = new QueryWrapper<ItemQueryInfo>();
//        titleInfoWrapper.lambda().eq(ItemQueryInfo::getCurrTestId,currTestId);
        ItemQueryInfo titleInfo = titleInfoMapper.selectOne(titleInfoWrapper);
        return titleInfo;
    }

    @Override
    public ItemResultInfo queryResultInfo(String startTestBtnApi) {
        QueryWrapper<ItemResultInfo> resultInfoWrapper = new QueryWrapper<ItemResultInfo>();
//        resultInfoWrapper.lambda().eq(ItemResultInfo::getStartTestBtnApi,startTestBtnApi);
        ItemResultInfo resultInfo = resultInfoMapper.selectOne(resultInfoWrapper);
        return resultInfo;
    }
}
